package org.amicofragile.simpledsl;

import org.amicofragile.simpledsl.Optimizer1;

import groovy.util.GroovyTestCase;

class Optimizer1Test extends GroovyTestCase {
	public void testFoo() {
		def evenOddCriteria = {
			it % 2 == 0 ? 'even' : 'odd'
		}
		
		def processedList = Optimizer1.withCriteria(evenOddCriteria).
			addGroupProcessor('odd', {it.inject(1) { acc, val -> acc * val }}).
			addGroupProcessor('even',{it.sort()}).
			process ([1, 3, 6, 4, 10, 2, 5, 3]);

		assertArrayEquals([3, 2, 4, 6, 10, 15].toArray(), processedList.toArray())
	}
}
